var isEnabled = true;

var typengo = {
	onKeyPress: function(event) {
		if (!isEnabled) return;

		var targetType = event.target.tagName.toLowerCase();

		if (targetType == "html" || targetType == "window")
		{
			event = window.event || event;
			var code = event.charCode;

			if (code > 0)
			{
				var urlbar = document.getElementById("urlbar");
				urlbar.focus();
				urlbar.value = String.fromCharCode(code);
			}
		}
	},
	onStatusBarClick: function(event) {
		isEnabled = !isEnabled;
		var typengoPanel = document.getElementById('typengo-panel')
		typengoPanel.label = isEnabled ? "Type n' Go" : "Type not Go";
		typengoPanel.setAttribute("tooltiptext", isEnabled ? "Enabled" : "Disabled");
	},
};

window.addEventListener("keypress", function(event) { typengo.onKeyPress(event); }, false);
